<?php 
    $this->model = new Areas_Navigation_Models_Navigation();
?>
<?php $this->section->begin('breadcrumb')?>
<div id="global-breadcrumb">
	<ul>
		<li><a href="<?php echo $this->url->action("index", "Manager", "Navigation")?>">Menu</a></li>
		<li><a href="<?php echo $this->url->action("list", "Manager", "Navigation", array($navType))?>"><?php echo $heading?></a></li>
		<li class="current">Thêm mục <?php echo $heading?></li>
	</ul>
</div>
<?php $this->section->end()?>
<?php $this->content->begin()?>
<div class="widget-shell inner-shadow">
	<div class="widget-header">
		<h2>Thêm mục <?php echo $heading?></h2>
	</div>
	<div class="widget-body">
		<?php
		    $ajaxOption['begin'] = "begin";
		    $ajaxOption['success'] = "success";
		    $this->form->beginAjax($ajaxOption);
		?>
			<div class="global-form">
				<div class="half margin-bottom-20">
				    <?php $this->form->labelFor("parent_id", array('class' => 'normal-label'))?>
				    <?php $this->form->selectFor("parent_id", $menuOptions, null, null, array('class' => 'normal'))?>
				    <?php $this->form->validationMessage("parent_id")?>
				</div>
				<div class="fclear"></div>
				<div class="half margin-bottom-20">
					<?php $this->form->labelFor("title", array('class' => 'normal-label'))?>
					<?php $this->form->textboxFor("title", array('class' => 'normal'))?>
					<?php $this->form->validationMessage("title")?>
				</div>
				<div class="fclear"></div>
				<div class="margin-bottom-20">
					<?php $this->form->labelFor("description", array('class' => 'normal-label'))?>
					<?php $this->form->textareaFor("description", array('class' => 'normal markItUpEditor'))?>
					<?php $this->form->validationMessage("description")?>
				</div>
				<div class="fclear"></div>
				<div class="half margin-bottom-20">
				    <?php $this->form->labelFor("sort", array('class' => 'normal-label'))?>
				    <?php $this->form->textboxFor("sort", array('class' => 'normal'))?>
				    <?php $this->form->validationMessage("sort")?>
				</div>
				<div class="fclear"></div>
				<div class="half margin-bottom-20">
				    <?php $this->form->labelFor("item_type", array('class' => 'normal-label'))?>
				    <?php $this->form->selectFor("item_type", $menuTypeOptions, null, null, array('class' => 'normal', 'rel' => $this->url->action("changeMenuType")))?>
				</div>
				<div class="fclear"></div>
				<div id="menu_type_container"></div>
			</div>
			<div class="alert alert-info alert-loading" style="margin-bottom: 0; display: none;">
				<p><span class="ico-text ico-alert-loading"></span><span>Đang thêm mục menu vào hệ thống...</span></p>
			</div>
			<div class="alert alert-error" style="margin-bottom: 0; display: none;">
				<p><span class="ico-text ico-alert-error"></span><span id="errorMessage"></span></p>
			</div>
			<div class="alert alert-success" style="margin-bottom: 0; display: none;">
				<p><span class="ico-text ico-alert-success"></span><span id="successMessage"></span></p>
			</div>
			<div class="global-form-footer">
				<input class="btn-theme" id="submit" type="submit" value="Thêm mới">
				<input id="reset" type="reset" value="Xóa trắng">
				<a href="<?php echo $this->url->action("list", "Manager", "Navigation", array($navType))?>" class="button">
    				<span class="ico-text ico-text-category"></span>Menu
    			</a>
			</div>
		<?php $this->form->end()?>
	</div>
</div>
<?php $this->content->end()?>
<?php $this->section->begin("scripts")?>
<?php 
//Load js
$this->html->loadJs(array(
                        'Scripts/jquery.validate.min.js',
                        'Scripts/jquery.validate.unobtrusive.min.js',
                        'Scripts/jquery.unobtrusive-ajax.min.js',
                        'Areas/ControlPanel/Assets/js/controlpanel.js'
                    ));
?>
<script type="text/javascript">
$(function(){
	$("#item_type").change(function(){
		$.ajax({
			url: $(this).attr('rel'),
			type: "post",
			data: {item_type: $(this).val()},
			success: function(res){
				$("#menu_type_container").html(res);
				$('#menu_type_container select').selectmenu({style:'dropdown'});
			}
		});
	});
	$("#item_type").change();
});
</script>
<?php $this->section->end()?>